Java program log: java. util. logging. Logger class,1. Logger level
More detailed than the log4j Level, all defined in java. util. logging. Level.The levels are listed in descending order as follows:SEVERE (maximum value)WARNINGIN
class Logger
Java.lang.Object
Java.util.logging.Logger
The Logger object is used to record log messages for a particular system or application component. You typically use a dot-delimited hierarchical namespace to name Logger. Logger names can be arbitrary strings, but t
is the XML configuration file in the example: Plainlog4jconfig.xml. Here is the program that executes the configuration file: Files/externalxmltest.java: Import Org.apache.log4j.Logger; Import Org.apache.log4j.xml.DOMConfigurator; public class Externalxmltest { static Logger Logger = Logger.getlogger (Filetest.class); public static void Main (String args[]) { Do
(fully qualified) class name. The appender must have a specified name and class. Embedded within Appender is the layout element, where it is designated as Simplelayout. Layout must have a class attribute.The root element must be present and not quilt-like. The priority in the example is set to "Debug", and the set Appender is full of a appender-ref element. Ther
(fully qualified) class name. The appender must have a specified name and class. Embedded within Appender is the layout element, where it is designated as Simplelayout. Layout must have a class attribute.The root element must be present and not quilt-like. The priority in the example is set to "Debug", and the set Appender is full of a appender-ref element. Ther
class classes, and then change the name of the custom logger to the corresponding package name or class name
The class that needs to be consolidated is placed under the same package, with the XXXX.XXX package name for the logger definition, which will be played together bec
, if the parent logger level is not set, continue to find the parent's parent, finally found root, if the root set to use it, if root is not set, the default value of root is warning3. Generate some level of information on a logger, first and logger levels, if the message level is lower than Logger's EFFECTIVELEVL, the message is discarded and the message is no l
Singleton mode : Create global objects with local static (non-local static possible initialization problems)Select One of the implementations (Std::cerr, printf, file) by #ifdef, #ifndef, #if defined, and other conditional compilationsSetting some default values through environment variablesif"ORO_LOGLEVEL"0 ){...}Using nested classes to manage internal implementation log level (Info, Waring, Error) controlclass Logger { struct D; D* d; //}Use
with these logs,Myloghander decided the format, no handle, the default console output, the above code equals to add a new two output mode, one is the console is output to text, So now there are three ways of handling, two of which are consoles, which is why the console prints two times. The formatting section can be no, but the format may be ugly. Handle and formatter, see below for details.Logger's HandlerThe Handler object obtains the log information from the
Logger the corresponding property file in the installation JDK directory Jre/lib/logging.properties (for example, in my current machine is C:\Program files\java\jre6\lib\ Logging.properties)
Logging.properties file (logging.properties file contains logger configuration information, including where the log is exported, what level, etc.)
handlers= Java.util.logging
Set your own logger tool class
You can set a one-click switch.
You can set a global tag.
Relatively simple to use, log. I (TAG, "in testing..."); Replace with logger. I ("in testing ...");
CodeImplementation example:
Package com.com. test; import android. util. log; public class
Reprinted: http://whotodo.iteye.com/blog/1701596
In the object-oriented world, we can anthropomorphic objects. They not only possess resources (data), but also implement some functions (methods ). Logger is built in Java. Android also supports a log recorder that can write log information to the console or file.
package org.vhow.android; import java.io.IOException; import java.util.log
=org.apache.log4j.patternlayout
LOG4J.APPENDER.FILE.LAYOUT.CONVERSIONPATTERN=[%5P]%d{yyyy-mm-dd HH:mm:ss} [%t] (%f:%l)%m%n Log4j.appender.secondadpter=org.apache.log4j.dailyrollingfileappender log4j.appender.secondadpter.file=./log/ Second.log log4j.appender.secondadpter.datepattern= '. '
YYYY-MM-DD Log4j.appender.secondadpter.layout=org.apache.log4j.patternlayout LOG4J.APPENDER.SECONDADPTER.LAYOUT.CONVERSIONPATTERN=[%5P]%d{yyyy-mm-dd HH:mm:ss} [%t] (%f:%l)%m%n
iii. use of Secondlogger
You c
A sample code that uses Java.util.logging.Logger for log output is as follows:
Package com.sample; Import Java.io.File; Import Java.util.logging.FileHandler; Import Java.util.logging.Handler; Import Java.util.logging.Level; Import Java.util.logging.Logger; Import Java.util.logging.SimpleFormatter; public class Loggersample {protected Logger Log=logger.getlogger (This.getclass (). GetName ()); public loggers
Use this can break through St2 forced JSP jump login.jspUsing jspx to resolve JSP suffixes is restricted to take shell-hack Blog | Hacker BlogHttp://www.hackblog.cn/post/45.htmlTwo "new" Javaweb backdoors (Jspx and Java Logger) | Hugtion ' s Bloghttps://www.hugtion.com/?p=768About the Javaweb back door problem has been relatively small, and relatively novel back door less. Here I share two more interesting
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.